public class Solution {
    public static int removeDuplicates(int[] A) {
        int len = A.length;

        if(len == 0)
            return 0;
        int index = 1;
        for(int i = 1; i < len; i++) {
            if(A[i] != A[index - 1]) {
                A[index++] = A[i];
            }
        }
        return index;
    }
}
